﻿#include "UdpClient.h"

#ifdef _WIN32
UdpClient::UdpClient()
{
    //AF_INET
    clientAddr.sin_family = AF_INET;
}

const char* UdpClient::IP() const
{
    return inet_ntoa(clientAddr.sin_addr);
}

unsigned int UdpClient::Port() const
{
    return clientAddr.sin_port;
}

void UdpClient::SetIP(const char* host)
{
    clientAddr.sin_addr.S_un.S_addr = inet_addr(host);
}

void UdpClient::SetPort(const unsigned int port)
{
    clientAddr.sin_port = htons(port);
}
#endif


#ifdef __linux__

UdpClient::UdpClient()
{
    //AF_INET
    clientAddr.sin_family = AF_INET;
}

const char *UdpClient::IP() const
{
    return inet_ntoa(clientAddr.sin_addr);
}

unsigned int UdpClient::Port() const
{
    return clientAddr.sin_port;
}

void UdpClient::SetIP(const char *host)
{
    clientAddr.sin_addr.s_addr = inet_addr(host);
}

void UdpClient::SetPort(unsigned int port)
{
    clientAddr.sin_port = htons(port);
}
#endif




